package com.example.webdatabinder.config;

import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;

import java.util.Date;

/**
 * 通过ControllerAdvice定义全局绑定器
 */
@ControllerAdvice
public class WebConfig {
    /**
     * 每次请求都会进入
     * @param webDataBinder
     */
    @InitBinder
    public void dateTypeBinder(WebDataBinder webDataBinder){
        webDataBinder.registerCustomEditor(Date.class,"mydate",new MyDateEditor());
    }
}
